package com.wisezone.demo0216;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;

public class ImgClient {
    public static void main(String[] args) {
        try{
            Socket socket=new Socket("127.0.0.1",9099);
            InputStream is= socket.getInputStream();

            File file=new File("out/img.jpg");
            FileOutputStream fos=new FileOutputStream(file);
            byte[] bytes=new byte[512];
            int len=-1;
//            len=is.read(bytes);
            while((len=is.read(bytes))!=-1){
                fos.write(bytes);
//                len=is.read(bytes);
            }
            socket.shutdownInput();

        }catch (UnknownHostException e){
            e.printStackTrace();
        }catch (IOException e){
            e.printStackTrace();
        }


    }
}
